package net.mihome.app.adapter;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.view.ViewGroup;

import net.mihome.app.ui.MifuwuFragment;
import net.mihome.app.ui.MineFragment;

/**
 * Created by ZHAO on 2014/12/29 0029.
 */
public class MifuwuFragmentAdapter extends FragmentPagerAdapter {
    MifuwuFragment mifuwuFragment;
    MineFragment mineFragment;
    public MifuwuFragmentAdapter(FragmentManager fm) {
        super(fm);
    }

    @Override
    public Fragment getItem(int i) {
        try{
            switch (i) {
                case 0:
                    if(mifuwuFragment==null) {
                        mifuwuFragment= MifuwuFragment.newInstance();
                    }
                    return mifuwuFragment;
                case 1:
                    if(mineFragment==null) {
                        mineFragment = new MineFragment();
                    }
                    return mineFragment;
                default:{
                    if(mifuwuFragment==null){
                        mifuwuFragment=MifuwuFragment.newInstance();
                    }
                    return mifuwuFragment;
                }
            }
        }catch (Exception e){
            e.printStackTrace();
            return mifuwuFragment;
        }
    }


    @Override
    public int getCount() {
        return 2;
    }

    @Override
    public void destroyItem(ViewGroup container, int position, Object object) {
        return;
//        super.destroyItem(container, position, object);
    }
}
